const express    = require('express');
const app        = express();
const bodyParser = require('body-parser');
const port       = process.env.PORT || 3000;

const history = require('connect-history-api-fallback');

app.use(history());
app.use(express.static(__dirname + '/static'));

// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }));

// parse application/json
app.use(bodyParser.json());

// define a route handler for the default home page
app.get('/person', (req, res) => {
  res.send({
    name: 'John Doe',
    age: 30,
    occupation: 'Software Engineer'
  });
});

// start the server
app.listen(port, () => {
  console.log(`Server running on port ${port}`);
});